


#ifndef PF_DIMLINEAR_H
#define PF_DIMLINEAR_H

#include "pf_dimension.h"
#include "lx_Export.h"
/**
 * Holds the data that defines a linear dimension entity.
 */
class LX_EXPORT PF_DimLinearAttribute {
public:
    /**
     * Default constructor. Leaves the data object uninitialized.
     */
    PF_DimLinearAttribute() {}

    /**
     * Constructor with initialisation.
     *
     * @para extensionPoint1 Startpoint of the first extension line.
     * @para extensionPoint2 Startpoint of the second extension line.
     * @param angle Rotation angle in rad.
     * @param oblique Oblique angle in rad.
     */
    PF_DimLinearAttribute(const PF_Vector& extensionPoint1,
                     const PF_Vector& extensionPoint2,
                     double angle, double oblique) {
        this->extensionPoint1 = extensionPoint1;
        this->extensionPoint2 = extensionPoint2;
        this->angle = angle;
        this->oblique = oblique;
    }

    friend class PF_DimLinear;
    friend class WF_DimLinear;

    friend std::ostream& operator << (std::ostream& os,
                                      const PF_DimLinearAttribute& dd) {
        os << "(" << dd.extensionPoint1 << "/" << dd.extensionPoint1 << ")";
        return os;
    }

public:
    /** Definition point. Startpoint of the first definition line. */
    PF_Vector extensionPoint1;
    /** Definition point. Startpoint of the second definition line. */
    PF_Vector extensionPoint2;
    /** Rotation angle in rad. */
    double angle;
    /** Oblique angle in rad. */
    double oblique;
};



/**
 * Class for aligned dimension entities.
 *

 */
class LX_EXPORT PF_DimLinear : public PF_Dimension {
public:
    PF_DimLinear(PF_Container* parent,
                 const PF_DimensionAttribute& d,
                 const PF_DimLinearAttribute& ed);
    virtual ~PF_DimLinear() {}

    virtual PF_Entity* clone() {
        PF_DimLinear* d = new PF_DimLinear(*this);
        d->setOwner(isOwner());
        d->initId();
        d->detach();
        return d;
    }

    /**	@return LX_Define::EntityDimLinear */
    virtual LX_Define::EntityType rtti() const {
        return LX_Define::EntityDimLinear;
    }

    /**
     * @return Copy of data that defines the linear dimension. 
     * @see getData()
     */
    PF_DimLinearAttribute getEData() const {
        return edata;
    }
	
    virtual PF_VectorSolutions getRefPoints();

    virtual QString getMeasuredLabel();

    virtual void update(bool autoText=false);

    PF_Vector getExtensionPoint1() {
        return edata.extensionPoint1;
    }

    PF_Vector getExtensionPoint2() {
        return edata.extensionPoint2;
    }

    double getAngle() {
        return edata.angle;
    }

	void setAngle(double a) {
		edata.angle = PF_Math::correctAngle(a);
	}

    double getOblique() {
        return edata.oblique;
    }

	virtual bool hasEndpointsWithinWindow(PF_Vector v1, PF_Vector v2);

    virtual void move(PF_Vector offset);
    virtual void rotate(PF_Vector center, double angle);
    virtual void scale(PF_Vector center, PF_Vector factor);
    virtual void mirror(PF_Vector axisPoint1, PF_Vector axisPoint2);
    virtual void stretch(PF_Vector firstCorner,
                         PF_Vector secondCorner,
                         PF_Vector offset);
	virtual void moveRef(const PF_Vector& ref, const PF_Vector& offset);

    friend std::ostream& operator << (std::ostream& os,
                                      const PF_DimLinear& d);

protected:
    /** Extended data. */
    PF_DimLinearAttribute edata;
};

#endif
